<!DOCTYPE html>
<html>
	<head>
		<meta charset="utf-8">
		<title></title>
		<script type="text/javascript">
			let colors=[]
			function ppt(){
				let xhr =new XMLHttpRequest()
					xhr.open("GET","colors.xml",true)
					xhr.send()
					xhr.onreadystatechange=function(){
					if (xhr.readyState == 4&&xhr.status==200) {
						let data=xhr.responseXML
						colors = data.getElementsByTagName("color")
						let select = document.querySelector("select")
						for (let i = 0; i < colors.length; i++) {
							select.options[i]=new Option(colors[i].querySelector("name").innerHTML)
						}
						let c=colors[0].querySelector("value").innerHTML
						document.body.setAttribute("style","background-color: "+c+";")
					} 
				}
			}
			function fun(){
				let select = document.querySelector("select")
				let index = select.selectedIndex
				let c=colors[index].querySelector("value").innerHTML
				document.body.setAttribute("style","background-color: "+c+";")
			}
		</script>
	</head>
	<body onload="ppt()">
		请选择背景颜色：<select onchange="fun()"></select>
	</body>
</html>
